﻿#pragma warning(disable: 4477)
#pragma warning(disable: 4996)
#pragma warning(disable: 6031)
#pragma warning(disable: 6054)
/*
 */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <assert.h>

typedef double Real;
const Real PI = 3.14159265359;

typedef struct TContext_s
{
	int cmd;
	Real r;
	Real h;
	int n;
	int v[10];
}TContext;

TContext context;

#define PROMPT_ 1

int read_data(TContext* ctx)
{
#if PROMPT_
	printf("1-Ball\n");
	printf("2-Cylinder\n");
	printf("3-Cone\n");
	printf("other-Exit\n");
	printf("Please enter your command:\n");
	//printf("1-Ball\n2-Cylinder\n3-Cone\nother-Exit\nPlease enter your command:\n");
#endif
	scanf("%d", &ctx->cmd);
	switch (ctx->cmd)
	{
	case 1:
#if PROMPT_
		printf("Please enter the radius:\n");
#endif
		scanf("%lf", &ctx->r);
		break;
	case 2:
	case 3:
#if PROMPT_
		printf("Please enter the radius and the height:\n");
#endif
		scanf("%lf %lf", &ctx->r,&ctx->h);
		break;
	default:
		return 0;
		break;
	}
	return 1;
}

void do_task(TContext* ctx)
{
	while (read_data(ctx))
	{
		switch (ctx->cmd)
		{
		case 1:
			printf("%.2f\n", PI / 3 * 4 * ctx->r * ctx->r * ctx->r);
			break;
		case 2:
			printf("%.2f\n", PI * ctx->h * ctx->r * ctx->r);
			break;
		case 3:
			printf("%.2f\n", PI /3 * ctx->h * ctx->r * ctx->r);
			break;
		}
	}
}

void solve(TContext* ctx)
{
	do_task(ctx);
}

int main()
{
	freopen("D:/Develop/GitRepos/MOOC/浙江大学/数据结构/201906/DataStructure/M2019秋C入门和进阶练习集/7-130.txt", "r", stdin);
	solve(&context);
	return 0;
}
